package com.hzqy.service.epg;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.hzqy.persistence.dao.epg.AcProductDao;
import com.hzqy.web.vo.epg.ActivityProductVo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class AcProductService {
	protected final Logger LOG = LoggerFactory.getLogger(getClass());
	
	@Resource
	private AcProductDao acDao;
	public int updateAc(ActivityProductVo apv){
	    return acDao.updateAc(apv);
    }
    public List<ActivityProductVo> selectByReq(ActivityProductVo apv){
		return acDao.selectByRequest(apv);
	}
	public  ActivityProductVo selectById(ActivityProductVo apv){
	    return acDao.selectActivity(apv.getF_ap_id());
    }
	public ActivityProductVo selctActivity(int f_ap_id){
	    return  acDao.selectActivity(f_ap_id);
    }
	public List<ActivityProductVo> selectAc(Map map){
		return acDao.selectAc(map);
	}
	public int deleteAc(ActivityProductVo apv){
		return acDao.deleteAc(apv);
	}
	public int insertAc(ActivityProductVo apv) {
		int i =acDao.insertAc(apv);
		return i;
	}
	public  Map<String, Object> selectAcExcelList(ActivityProductVo ac){
        Map<String,Object> map = new HashMap<String, Object>();
        Integer rowCount = acDao.selectAcCount(ac);
        map.put("total", rowCount);
        if(rowCount > 0) {
            map.put("f_ap_id",ac.getF_ap_id());
            map.put("f_ap_name", ac.getF_ap_name());
            map.put("f_ap_desc",ac.getF_ap_desc());
            map.put("f_ap_type",ac.getF_ap_type());
            map.put("f_ap_productcode",ac.getF_ap_productcode());
            map.put("f_ap_status",ac.getF_ap_status());
            map.put("f_ap_heaven",ac.getF_ap_heaven());
            map.put("f_ap_frequency",ac.getF_ap_frequency());
            map.put("f_ap_startdate",ac.getF_ap_startdate());
            map.put("f_ap_enddate",ac.getF_ap_enddate());
            map.put("f_ap_udate",ac.getF_ap_udate());
            map.put("f_ap_cdate",ac.getF_ap_cdate());
            List<ActivityProductVo> results = acDao.selectAc(map);
            map.put("rows", results);
        } else {
            map.put("rows", new ArrayList<ActivityProductVo>());
        }
        return map;
    }
}
